/* 
 * Copyright 2014 ShangDao.Ltd  All rights reserved.
 * SiChuan ShangDao.Ltd PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * 
 * @ActAbout.java  2014-9-12 下午2:21:32 - Carson
 * @author Guzhu
 * @email:muyi126@163.com
 * @version 1.0
 */

package com.android.tiango.baba.act;

import java.lang.reflect.Field;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ZoomButtonsController;

import com.android.scsd.tiango.R;
import com.android.tiango.baba.BaBaseActivity;
import com.android.tiango.baba.util.Constants;
import com.android.tiango.baba.view.AppTitleBar;

/**
 * 关于
 * @author YW_pc
 * 
 */
public class ActAbout extends BaBaseActivity {
	private WebView webView;
	private String mTitleSource;
	private String mStringspath;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.layout_help_detail);
		initViews();
	}

	private void initViews() {
		mTitleBar = (AppTitleBar) findViewById(R.id.titlebar);
		webView = (WebView) findViewById(R.id.web);

		Intent intent = getIntent();
		if (intent.hasExtra(Constants.NAME) && intent.hasExtra(Constants.DATA)) {
			mTitleSource = intent.getStringExtra(Constants.NAME);
			mStringspath = intent.getStringExtra(Constants.DATA);
		}
		mTitleBar.setTitle(mTitleSource);
		setBackOnClickListener();
		webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		WebSettings webSettings = webView.getSettings();
		// webSettings.setJavaScriptEnabled(true);
		webSettings.setBuiltInZoomControls(true);
		// webView.getSettings().setUseWideViewPort(true);
		// webView.getSettings().setLoadWithOverviewMode(true);
		webView.setBackgroundColor(Color.WHITE);
		webView.getSettings().setDefaultTextEncodingName("utf-8");
		setZoomControlGone(webView);
		webView.loadUrl(mStringspath);
	}

	public void setZoomControlGone(View view) {
		Class classType;
		Field field;
		try {
			classType = WebView.class;
			field = classType.getDeclaredField("mZoomButtonsController");
			field.setAccessible(true);
			ZoomButtonsController mZoomButtonsController = new ZoomButtonsController(view);
			mZoomButtonsController.getZoomControls().setVisibility(View.GONE);
			try {
				field.set(view, mZoomButtonsController);
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		}
	}
}
